--- sdf_utils_1.py	2024-02-15 10:14:37.382027473 -0500
+++ sdf_utils.py	2024-02-13 10:46:24.640644943 -0500
@@ -1,18 +1,19 @@
+# from https://raw.githubusercontent.com/ashawkey/torch-ngp/main/sdf/utils.py
+
+
 import os
 import glob
 import tqdm
 import random
 import warnings
-import tensorboardX
+# import tensorboardX
 
 import numpy as np
-import pandas as pd
 
 import time
 from datetime import datetime
 
 import cv2
-import matplotlib.pyplot as plt
 
 import torch
 import torch.nn as nn
@@ -23,18 +24,13 @@
 
 import trimesh
 import mcubes
-from rich.console import Console
-from torch_ema import ExponentialMovingAverage
 
-import packaging
 
 def custom_meshgrid(*args):
-    # ref: https://pytorch.org/docs/stable/generated/torch.meshgrid.html?highlight=meshgrid#torch.meshgrid
-    if packaging.version.parse(torch.__version__) < packaging.version.parse('1.10'):
-        return torch.meshgrid(*args)
-    else:
+    try: 
         return torch.meshgrid(*args, indexing='ij')
-
+    except:
+        return torch.meshgrid(*args)
 
 def seed_everything(seed):
     random.seed(seed)
@@ -54,8 +50,8 @@
 
     u = np.zeros([resolution, resolution, resolution], dtype=np.float32)
     with torch.no_grad():
-        for xi, xs in enumerate(X):
-            for yi, ys in enumerate(Y):
+        for xi, xs in enumerate(tqdm.tqdm(X)):
+            for yi, ys in enumerate(tqdm.tqdm(Y)):
                 for zi, zs in enumerate(Z):
                     xx, yy, zz = custom_meshgrid(xs, ys, zs)
                     pts = torch.cat([xx.reshape(-1, 1), yy.reshape(-1, 1), zz.reshape(-1, 1)], dim=-1) # [N, 3]
@@ -66,12 +62,13 @@
 
 def extract_geometry(bound_min, bound_max, resolution, threshold, query_func):
     #print('threshold: {}'.format(threshold))
+    print("Extracting fields")
     u = extract_fields(bound_min, bound_max, resolution, query_func)
-
+    print("Finished fields")
     #print(u.shape, u.max(), u.min(), np.percentile(u, 50))
-    
+    print("Computing marching cubes")
     vertices, triangles = mcubes.marching_cubes(u, threshold)
-
+    print("Finished marching cubes")
     b_max_np = bound_max.detach().cpu().numpy()
     b_min_np = bound_min.detach().cpu().numpy()
 
@@ -123,6 +120,8 @@
         self.time_stamp = time.strftime("%Y-%m-%d_%H-%M-%S")
         self.scheduler_update_every_step = scheduler_update_every_step
         self.device = device if device is not None else torch.device(f'cuda:{local_rank}' if torch.cuda.is_available() else 'cpu')
+        
+        from rich.console import Console
         self.console = Console()
 
         model.to(self.device)
@@ -146,6 +145,7 @@
             self.lr_scheduler = lr_scheduler(self.optimizer)
 
         if ema_decay is not None:
+            from torch_ema import ExponentialMovingAverage
             self.ema = ExponentialMovingAverage(self.model.parameters(), decay=ema_decay)
         else:
             self.ema = None
